import java.util.Arrays;
import java.util.PriorityQueue;

public class Congress {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Congress();
	}
	
	private int seatsLeft;
	private PriorityQueue<State> states = new PriorityQueue<State>();
	
	/**
	 * New CongressCalculation
	 */
	public Congress() {
		//Read the file
		readFile();
		
		//Make calculations
		while(seatsLeft > 0) {
			giveSeat();
		}
		
		//Print output
		printOutput();
	}
	
	/**
	 * Read the input
	 */
	private void readFile() {
		
		int numberOfStates = Integer.parseInt(StdIn.readLine());
		seatsLeft = Integer.parseInt(StdIn.readLine());
		
		for(int i = 0; i < numberOfStates; i++) {
			
			String name = StdIn.readLine();
			double pop = Double.parseDouble(StdIn.readLine());
		
			State state = new State(name,pop);
			states.add(state);
			seatsLeft--;
		}
	} 
	
	/**
	 * Give Away a seat
	 */
	private void giveSeat() {
		State state = states.poll();
		state.seats++;
		state.calPriority();
		states.add(state);
		seatsLeft--;
	}
	
	/**
	 * Print output
	 */
	private void printOutput() {
            String[] out = new String[states.size()];
            int i = 0;
            for(State state : states) {
                out[i++]=state.name + " " + state.seats;
            }
            Arrays.sort(out);
            for(String s : out){
                StdOut.println(s);
            }
	}
}
